script_enemy_main{

let character="Nanami";
let cutin=character;
let spellcards=3;
let spellcardnumber=43;
let dispelled=0;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshots3=("\script\SoundEffects\shots3.wav");
let SEshotb6=("\script\SoundEffects\shotb6.wav");
let SElaserm1=("\script\SoundEffects\laserm1.wav");

let BG1=("\script\Images\BackgroundLayers\Nanami1.png");
let BG2=("\script\Images\BackgroundLayers\Nanami2.png");
let GRboss=("\script\Images\CharacterSprites\Nanami.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsNanami1.txt");
	
	LoadSE("script\SoundEffects\shots3.wav");
	LoadSE("script\SoundEffects\shotb6.wav");
	LoadSE("script\SoundEffects\laserm1.wav");

	LoadGraphic("\script\Images\CharacterSprites\Nanami.png");
	LoadGraphic("\script\Images\BackgroundLayers\Nanami1.png");
	LoadGraphic("\script\Images\BackgroundLayers\Nanami2.png");

	SetScore(500000);
	SetLife(300);
	SetTimer(45);
	SetInvincibility(120);
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	SetMovePosition02(cx,miny+120,50);
	
	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));	

	SetCommonData("Boss1Vanish",1);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(32,32,32,32);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=5; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Appetizer [Spaghetti With Meatballs]",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(time%200==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+80,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+80,miny+120),1.5);
	}
}


if(time%2==0 && time>=60){
	SetShotColor(255,0,0);
	CreateShot01(GetX,GetY,rand(2,2.5),-(time*2.5)+rand(-5,5),25,10);
	SetShotColor(255,255,255);
if(time%6==0){ PlaySE(SEshots3); }
}

if(time%20==0 && time>=60){
let xpos=cx+170*cos(time*1.3);
let shot1=0;
let delay=0;
let turntime=20;
let curve=rand(-1.5,1.5);
let speed=2.5;
	CreateLaserC(shot1,xpos,miny-rand(5,50),10,100,87,0);
	SetLaserDataC(shot1,0,speed,90+rand(-10,10),curve,0,0);
		loop(10){
		SetLaserDataC(shot1,delay+turntime,speed,NULL,-curve,0,0);
		SetLaserDataC(shot1,delay+turntime*3,speed,NULL,0,0,0);
		SetLaserDataC(shot1,delay+turntime*4,speed,NULL,curve,0,0);
		SetLaserDataC(shot1,delay+turntime*6,speed,NULL,0,0,0);
		delay+=turntime*6;
		}
	FireShot(shot1);
	PlaySE(SElaserm1);
}

if(time%45==0 && time>=60){
let angle=time*1.3;
	loop(14){
	SetShotColor(255,150,150);
	CreateShot01(GetX,GetY,2,angle,98,10);
	angle+=360/14;
	SetShotColor(255,255,255);
	}
PlaySE(SEshotb6);
}


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<120){ bgfade+=5; }

	SetGraphicRect(0,0,588,588);
	SetGraphicScale(1,1);
	SetTexture(BG1);
	SetAlpha(255);
	SetColor(bgfade,bgfade,bgfade);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,time/3);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0,0,300,300);
	SetGraphicScale(1.4,1.4);
	SetTexture(BG2);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
//	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,5);
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}